package com.xiaoniu.lib_keleim.db.manager;

import android.app.Application;

import com.xiaoniu.lib_keleim.pojo.vos.UserInfoVO;
import com.xiaoniu.lib_keleim.db.ConversationListCallBack;
import com.xiaoniu.lib_keleim.db.MessageListCallBack;
import com.xiaoniu.lib_keleim.pojo.vos.BaseMessage;
import com.xiaoniu.lib_keleim.pojo.vos.MessageConversationVO;
import com.xiaoniu.lib_keleim.pojo.dos.UserEntity;

import java.util.List;

public class MessageDao {


    private IDBDaoManager mDBDaoManagerImpl;

    private static MessageDao mDBManager;


    private MessageDao(Application application) {
        mDBDaoManagerImpl = new DBDaoManagerImpl();
        mDBDaoManagerImpl.initDB(application);
    }

    public static void init(Application application) {
        mDBManager = new MessageDao(application);
    }

    public static MessageDao getInstance(){
        return mDBManager;
    }

    public void updateUserEntity(UserInfoVO data) {
        mDBDaoManagerImpl.updateUserEntity(data);
    }

    public void updateUserEntity(UserEntity data) {
        mDBDaoManagerImpl.updateUserEntity(data);
    }

    public UserEntity queryTargetUserEntity(long customerId) {
        return mDBDaoManagerImpl.getUserEntity(customerId);
    }

    public void updateMessageEntity(BaseMessage data) {
        mDBDaoManagerImpl.insertIncomingMessage(data);
    }

    public void updateMessageEntityArray(List<BaseMessage> data) {
        mDBDaoManagerImpl.updateMessageEntityArray(data);
    }

    public void updateConversationEntityArray(List<MessageConversationVO> data) {
        mDBDaoManagerImpl.updateConversationEntityArray(data);
    }

    public void updateConversationEntity(MessageConversationVO data) {
        mDBDaoManagerImpl.updateConversationEntity(data);
    }

    public void getConversationListByPage(ConversationListCallBack callback) {
        mDBDaoManagerImpl.getConversationListByPage(0, 50,callback);
    }

    public void getHistoryMessages(long targetId, MessageListCallBack callback) {
        mDBDaoManagerImpl.getHistoryMessages(targetId,0, 50,callback);
    }
}
